import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { ElMessage } from 'element-plus'

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(router)
app.use(ElementPlus, {
  locale: zhCn
})

// 配置全局Message设置
app.config.globalProperties.$message = {
  success: (message) => {
    ElMessage({
      message,
      type: 'success',
      center: true,
      showClose: true
    })
  },
  error: (message) => {
    ElMessage({
      message,
      type: 'error',
      center: true,
      showClose: true
    })
  },
  info: (message) => {
    ElMessage({
      message,
      type: 'info',
      center: true,
      showClose: true
    })
  },
  warning: (message) => {
    ElMessage({
      message,
      type: 'warning',
      center: true,
      showClose: true
    })
  }
}

app.mount('#app')


